from django.urls import path
from rest_framework.routers import DefaultRouter
from apps.meiduo_admin.login import admin_jwt_token
from apps.meiduo_admin.views.admin_view import AdminSimpleAPIView, AdminView
from apps.meiduo_admin.views.count_views import UserDailyActiveCountView, UserDailyOrderCountView, UserMonthCountView, \
    UserDayCountView, UserCountView, UserGoodsView
from apps.meiduo_admin.views.group_view import GroupView, GroupSimpleAPIView
from apps.meiduo_admin.views.image_view import ImageView, SKUView
from apps.meiduo_admin.views.permission_view import PermissionView, ContentTypeAPIView
from apps.meiduo_admin.views.sku_view import SKUModelViewSet, SKUCateGoryView, GoodsSimpleView
from apps.meiduo_admin.views.user_view import UserListView

urlpatterns = [
    # 添加返回token的view
    path('authorizations/', admin_jwt_token),
    # 日活跃用户统计
    path('statistical/day_active/', UserDailyActiveCountView.as_view()),
    # 日下单用户量统计
    path('statistical/day_orders/', UserDailyOrderCountView.as_view()),
    # 月增用户量统计
    path('statistical/month_increment/', UserMonthCountView.as_view()),
    # 日增用户量统计
    path('statistical/day_increment/', UserDayCountView.as_view()),
    # 用户总量统计
    path('statistical/total_count/', UserCountView.as_view()),
    # 日分类商品访问量统计
    path('statistical/goods_day_views/', UserGoodsView.as_view()),
    # 查询用户
    path('users/', UserListView.as_view()),
    # 获取sku表id
    path('skus/simple/', SKUView.as_view()),
    # 获取三级分类信息
    path("skus/categories/", SKUCateGoryView.as_view()),
    # 获取SPU表名数据
    path('goods/simple/', GoodsSimpleView.as_view()),
    # 获取SPU商品规格信息
    path('goods/<int:pk>/specs/', GoodsSimpleView.as_view()),
    # 获取权限类型列表数据
    path('permission/content_types/', ContentTypeAPIView.as_view()),
    # 获取权限表数据
    path('permission/simple/', GroupSimpleAPIView.as_view()),
    path('permission/groups/simple/', AdminSimpleAPIView.as_view())
]
# 创建router实例
router = DefaultRouter()
# 注册路由
router.register(r"skus/images", ImageView, basename='image')
# 获取sku表数据
router.register(r"skus", SKUModelViewSet, basename='sku')
# 用户权限表
router.register(r"permission/perms", PermissionView, basename='perms')
# 获取用户组表列表数据
router.register(r"permission/groups", GroupView, basename='groups')
router.register(r"permission/admins", AdminView, basename='admins')
# 将router生成的路由追加到urlpatterns
urlpatterns += router.urls
